package com.chapter14.Map_;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class MapExercise {
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put(1, new Employee(1, "jack", 19000));
        map.put(2, new Employee(2, "mary", 17000));
        map.put(3, new Employee(3, "smith", 18000));
        Set set = map.keySet();
        for (Object o : set) {
            Employee e = (Employee) map.get(o);
            if (e.getSalary() < 18000) {
                continue;
            }
            System.out.println(o + "=" + map.get(o));
        }
        Set set1 = map.entrySet();
        Iterator iterator = set1.iterator();
        while (iterator.hasNext()) {
            Map.Entry next = (Map.Entry)  iterator.next();

            Employee next1 = (Employee) next.getValue();
            if (next1.getSalary() < 18000) {
                continue;
            }
            System.out.println(next);
        }

    }
}

class Employee {
    private int id;
    private String name;
    private double salary;

    public Employee(int id, String name, double salary) {
        this.id = id;
        this.name = name;
        this.salary = salary;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", salary=" + salary +
                '}';
    }
}
